package ycl.important.controller.region;


import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ycl.important.common.ApiResult;
import ycl.important.common.base.controller.BaseRegionController;
import ycl.important.entity.region.City;
import ycl.important.service.region.CityService;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 城市设置 前端控制器
 * </p>
 *
 * @author YCL
 * @since 2021-06-05
 */
@RestController
@RequestMapping("/region/city")
@Api(tags = "地区 - 城市")
@ApiSort(3)
public class CityController extends BaseRegionController {

	@Resource
	private CityService cityService;

	@Override
	public ApiResult<City> getById(Long id) {
		return ApiResult.success(cityService.getById(id));
	}

	@Override
	public ApiResult<City> getByCode(String code) {
		return ApiResult.success(cityService.getByCode(code, City.class));
	}

	@Override
	public ApiResult<List<City>> getByParentCode(String code) {
		return ApiResult.success(cityService.getByParentCode(code, City.class));
	}
}

